<script setup>
import { useCounterStore } from '@/stores/counter'
import getData from '@/apis/testApi'
import { userStore } from '@/stores/user'


const user = userStore()

const testUser = () => {
    const token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJhdWQiOiJhZG1pbiIsImV4cCI6MTc0ODYwNjQ1NSwiaWF0IjoxNzQ4NjAyODU1fQ.NCdcs25IqP_OC2qR2aMQovOaCkPpOyST9JKjw2cuGcs"
    user.saveToLocalStorage('test', token)
    console.log(user.isLogin)
}

const counter = useCounterStore()
const testApi = () => {
    getData().then(res => {
        console.log(res)
        alert(res.msg)
    })
}

</script>

<template>
    <button @click="testUser">testUser</button>
    <div>Current Count: {{ counter.count }}</div>
    <button @click="counter.increment">Increment</button>
    <button @click="counter.getList">getList</button>
    <button @click="testApi">测试网络调用</button>
    <ul>
        <li v-for="item in counter.list" :key="item.id">
            {{ item.name }}
        </li>
    </ul>
    <button @click="user.clearLocalStorage">注销</button>

</template>